package com.cj.demo6.controller;

import com.cj.demo6.pojo.User;
import com.cj.demo6.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@RestController
@Api(tags = "/User-用户管理")
@RequestMapping(value = "/user")
public class UserController {
    @Autowired
    UserService userService;

    @GetMapping("/selectAll")
    @ResponseBody
    @ApiOperation("查询所有用户")
    public List<User> selectALL(){
        return userService.selectAll();
    }

    @GetMapping("/insert")
    @ResponseBody
    @ApiOperation("插入新数据")
    public int insert(User user){
        return userService.insert(user);
    }

    @GetMapping("/update")
    @ResponseBody
    @ApiOperation("修改数据")
    public int update(User user){
        return userService.update(user);
    }

    @GetMapping("/delete")
    @ResponseBody
    @ApiOperation("删除数据")
    public int delete(@RequestParam("uId") int uId){
        return userService.delete(uId);
    }

    @GetMapping("/deletes")
    @ResponseBody
    @ApiOperation("批量删除数据")
    public int deletes(@RequestParam("uId") int[] uIds){
        return userService.deletes(uIds);
    }

    @GetMapping("/selectMapper")
    @ResponseBody
    @ApiOperation("查询所有用户接口")
    public List<User> selectMapper(User user){
        return userService.selectMapper(user);
    }

}
